package org.spider.s8;

import java.util.HashMap;
import java.util.Map;

import jodd.http.HttpBrowser;
import jodd.http.HttpRequest;

public class MyBrowser {
	private static MyBrowser myBrowser = new MyBrowser();
	private static HttpBrowser browser = new HttpBrowser();

	private MyBrowser() {
	}

	public static MyBrowser newInstance() {
		browser.setKeepAlive(true);
		return myBrowser;
	}
	
	public static HttpBrowser getBrowser() {
		return browser;
	}
	
	public HttpBrowser send(HttpRequest query) {
		Map<String,String> headers = new HashMap<String,String>();
		headers.put("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
		headers.put("Accept-Encoding","gzip, deflate");
		headers.put("Accept-Language","zh-CN,zh;q=0.9");
		headers.put("Cache-Control","max-age=0");
		headers.put("Connection","keep-alive");
		headers.put("Content-Type","application/x-www-form-urlencoded");
		headers.put("Host","sisqq.com");
		headers.put("Origin","http://sisqq.com");
		headers.put("Referer","http://sisqq.com/portal-2.html");
		headers.put("Upgrade-Insecure-Requests","1");
		headers.put("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36");
		query.header(headers);
		query.timeout(2000).connectionTimeout(2000);
		browser.sendRequest(query);
		return browser;
	}
}
